class Solution {
public:
    void merge(int A[], int m, int B[], int n) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
		int cur = m + n - 1;
		int index_a = m - 1;
		int index_b = n - 1;

		while (index_a >= 0 || index_b >= 0) {
			if (index_b < 0 || (index_a >= 0 && A[index_a] >= B[index_b])) {
				A[cur--] = A[index_a--];
			} else {
				A[cur--] = B[index_b--];
			}
		}
    }
};